<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>表格隔行变色</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .head {
        background-color: skyblue;
        text-align: center;
      }
      tr {
        height: 30px;
      }
      table {
        border-collapse: collapse;
      }
      td {
        padding: 0 5px;
        border-bottom: 1px solid gray;
      }
      .bg1 {
        background-color: #9bceea;
      }
      .bg2 {
        background-color: white;
      }
    </style>
  </head>
  <body>
    <table>
      <thead>
        <tr class="head">
          <th>代码</th>
          <th>名称</th>
          <th>最新公布净值</th>
          <th>累计净值</th>
          <th>前单位净值</th>
          <th>净值增长率</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>003526</td>
          <td>境内分行“农银菁穗”乡村振兴专项招聘公</td>
          <td>1.075</td>
          <td>1.079</td>
          <td>1.074</td>
          <td>+0.047%</td>
        </tr>
        <tr>
          <td>003526</td>
          <td>境内分行“农银菁穗”乡村振兴专项招聘公</td>
          <td>1.075</td>
          <td>1.079</td>
          <td>1.074</td>
          <td>+0.047%</td>
        </tr>
        <tr>
          <td>003526</td>
          <td>境内分行“农银菁穗”乡村振兴专项招聘公</td>
          <td>1.075</td>
          <td>1.079</td>
          <td>1.074</td>
          <td>+0.047%</td>
        </tr>
      </tbody>
    </table>
    <script>
      var trs = document.querySelector("tbody").querySelectorAll("tr");
      for (let i = 0; i < trs.length; i++) {
        trs[i].onmouseover = function () {
          trs[i].className = "bg1";
        };
        trs[i].onmouseout = function () {
          trs[i].className = "bg2";
        };
      }
    </script>
  </body>
</html>
